//
// Created by Valentina_HP on 2023/3/6.
//

#ifndef USER_APP_COMMON_INC_H
#define USER_APP_COMMON_INC_H


#ifdef __cplusplus
extern "C" {
#endif

#include "main.h"
#include "stdio.h"
#include "gpio.h"
#include "spi.h"
#include "adc.h"
#include "tim.h"
#include "usbd_cdc_if.h"

#include "common_thread_define.h"
#include "common_comm_ui_define.h"
#include "common_comm_foc_define.h"
#include "common_foc_ui_define.h"

#define OPEN_TEST 0

#define DEBUG_PRINTF 0


#define CMD_HEAD    0xEF
#define CMD_TAIL    0xFE
#define CMD_LEN     24


#define CMD_FILE            0x1A //文件更新类
#define CMD_FONT_BIG        0x01
#define CMD_FONT_MIDDLE     0x02
#define CMD_FONT_SMALL      0x03
#define CMD_FIRMWARE        0x04
#define CMD_ANIM_IMG        0x05
#define CMD_IMG             0x06


#define CMD_MOTOR           0x2A  //电机控制类

#define CMD_LCalibration    0x01
#define CMD_RCalibration    0x02
#define CMD_LRCalibration   0x03

#define CMD_OPEN_MODE       0x11  //开环
#define CMD_OPEN_LOPEN      0x01
#define CMD_OPEN_ROPEN      0x02
#define CMD_OPEN_LROPEN     0x03


#define CMD_I_MODE          0x12  //电流环
#define CMD_I_LI            0x01
#define CMD_I_RI            0x02
#define CMD_I_LRI           0x03

#define CMD_I_PARM          0x13  //电流环参数
#define CMD_IL_AIMI         0x01  //电流环参数
#define CMD_ILQ_PI          0x02  //电流环参数
#define CMD_ILD_PI          0x03  //电流环参数
#define CMD_IR_AIMI         0x04  //电流环参数
#define CMD_IRQ_PI          0x05  //电流环参数
#define CMD_IRD_PI          0x06  //电流环参数


#define CMD_SPEED_MODE          0x16  //速度环
#define CMD_SPEED_LSPEED        0x01
#define CMD_SPEED_RSPEED        0x02
#define CMD_SPEED_LRSPEED       0x03


#define CMD_SPEED_PARM          0x17  //速度环参数
#define CMD_SPEEDL_AIM          0x01
#define CMD_SPEEDL_PI           0x02
#define CMD_SPEEDR_AIM          0x03
#define CMD_SPEEDR_PI           0x04





#define CMD_STOP_LR         0x21  //暂停电机



#define CMD_SET_UqUd        0x31  //设置UqUd
#define CMD_LUqUd           0x01
#define CMD_RUqUd           0x02


#define CMD_SET_WaveMaxMin  0x41  //设置波形的最大最小
#define CMD_SET_TaTbTcMaxMin 0x01
#define CMD_SET_IaIbIcMaxMin 0x02
#define CMD_SET_IqIdMaxMin   0x03


void AppMain(void);

extern struct Aurora_UI2FOC_MSG ui2foc_msg; //用于UI发送FOC更新的邮箱
extern struct Aurora_FOC2UI_MSG foc2ui_msg; //用于FOC发送UI更新的邮箱


extern struct Aurora_COMM2UI_MSG comm2ui_msg;
extern struct Aurora_COMM2FOC_MSG comm2foc_msg;
#ifdef __cplusplus
}
#endif //USER_APP_COMMON_INC_H
#endif